home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / LEVEL1 / TNC320.AS < prev    next >
Text File  |  1990-11-14  |  10KB  |  306 lines

  1. ;/*
  2. ; * Copyright 1988 by the Radio Amateur Telecommunications Society
  3. ; * and Thomas A. Moulton, W2VY
  4. ; *
  5. ; * This software may only be modified, copied, distributed or
  6. ; * executed for non-profit purposes by individuals operating
  7. ; * systems in the Amateur Radio Service.  Credit to the
  8. ; * author(s) and to the Radio Amateur Telecommunications Society
  9. ; * must be made in modules where RATS provided software is used,
  10. ; * and in any announcements and documentation.  
  11. ; *
  12. ; * As a non-profit, research and development organization,  the
  13. ; * Radio Amateur Telecommunications Society distributes software
  14. ; * in both executable and source forms.  This policy is in place
  15. ; * to encourage the development and distribution of OSI-based,
  16. ; * networking tools.  In order to protect the interests of the
  17. ; * Society and the authors, we have placed some conditions
  18. ; * of use on the software.  Other groups are encouraged
  19. ; * to place the same or similar guidelines on
  20. ; * software they produce.
  21. ; *
  22. ; * The Radio Amateur Telecommunications Society reserves the right
  23. ; * to specify and alter the terms under which software provided by
  24. ; * the Society may be used.  This policy is consistent with the 
  25. ; * objective of uniform and consistent "Open Systems Interconnections."
  26. ; * 
  27. ; * All acceptable Amateur Radio related uses of this software
  28. ; * will be outlined in the "ROSE Implementer's Guide".  Individuals
  29. ; * or organizations wishing to add to, or modify the provisions of
  30. ; * the guide to accommodate local or evolutionary requirements
  31. ; * should document the proposed change(s) and forward them to the
  32. ; * Society.  If accepted, written notification will be provided by
  33. ; * the Society to the submitting organization or individual(s).
  34. ; * The Society will then issue a "ROSE Implementer's Guide Change
  35. ; * Notice".  Periodically, the Society will re-issue the "ROSE 
  36. ; * Implementer's Guide" and incorporate the text of the change 
  37. ; * notices.  This procedure has been put in to place to ensure
  38. ; * compatibility between systems and to ensure their "Openness"
  39. ; * and interoperability.
  40. ; *
  41. ; * No part of this software may be used in other packages 
  42. ; * without prior authorization from the author or the Society.  
  43. ; * Software incorporating this module, all or in part, must be 
  44. ; * provided to the Society prior to distribution or use by
  45. ; * anyone not directly involved in testing of the revised  
  46. ; * environment.  Current releases of the combined software must
  47. ; * be provided to the Society in both source and executable
  48. ; * forms.  Adequate documention to produce an executable module 
  49. ; * from the provided source must also be included.
  50. ; *
  51. ; * Non-Amateur Radio non-profit uses may be authorized on a case
  52. ; * by case basis.  Inquiries for such use may be made in writing
  53. ; * to the Society. Non-commercial uses consistent with the
  54. ; * general principles of Open Systems Interconnection Reference
  55. ; * Model will be generally considered with favor.
  56. ; *
  57. ; * Commercial licensing of the software is also available based
  58. ; * on normal commercial terms.  Licensing inquiries should be
  59. ; * directed to the Society.  Commercial licensing of the standard
  60. ; * software will be done in situations which materially benefit
  61. ; * the Amateur Radio Packet Network.  Additional licensing is
  62. ; * reserved by the individual authors.
  63. ; * 
  64. ; * The Radio Amateur Telecommunications Society provides this software
  65. ; * on an "as is" basis.  The Society assumes no liability for
  66. ; * loss incurred through the use of this software.  Amateur Radio
  67. ; * use of this software implies non-commercial and voluntary 
  68. ; * development, deployment and use of this software in a "Amateur",
  69. ; * non-commercial service.  Commercial users are encouraged to
  70. ; * inspect their copies of the source code.  Source code modification
  71. ; * licenses are available if a combined Object and Source Code
  72. ; * license was not originally established.
  73. ; * 
  74. ; * The Society may be contacted by writing or calling at:
  75. ; * 
  76. ; * The Radio Amateur Telecommunications Society 
  77. ; * 206 North Vivyen Street.
  78. ; * Bergenfield, New Jersey 07621
  79. ; *
  80. ; * Telephone: 201-387-8896
  81. ; *
  82. ; */
  83. ;
  84. ; System Init for ROM
  85. ;
  86.     psect    text,pure
  87.  
  88. *INCLUDE RCONFIG.LIB
  89. *INCLUDE STRUCT.LIB
  90.  
  91. MSYNC    EQU    10H
  92. CTS    EQU    5        ;SIO RR0 CTS Bit (Mask 20h)
  93. MDCD    EQU    08H
  94. MRTS    EQU    02H
  95.  
  96. POWER_FAIL EQU    0150H
  97.  
  98.     GLOBAL    CLKBIT, TICKCNT, HDWbss, HDLI
  99.  
  100.     psect    text
  101. start:    di            ;Insure NO int's!!
  102.     jp    POWER_FAIL    ;Power Failure, check memory, etc
  103.     jp    INIT_HDW    ;Set up SDS's based on the machine type
  104.     jp    INIT_LED    ;Init Led's
  105.     jp    UPD_LED        ;Change Led's (toggle)
  106.     jp    halted        ;We are halted...
  107.  
  108.     global    amul, brelop, wrelop, csv, cret
  109.  
  110. RST2:    jp    (hl)        ;for optimizer    **********'0010'**************
  111.     defm    'PacComm'
  112. RST3:    jp    amul        ;for optimizer    **********'0018'**************
  113.     defm    'TNC -'
  114. RST4:    jp    brelop        ;for optimizer    **********'0020'**************
  115.     defm    '320HF'
  116. RST5:    jp    wrelop        ;for optimizer    **********'0028'**************
  117.     defm    'W2VY'
  118.     defb    0
  119. RST6:    jp    csv        ;for optimizer    **********'0030'**************
  120.     defm    'ROSE'
  121.     defb    0
  122. RST7:    ex    (sp),hl        ;for optimizer    **********'0038'**************
  123.     pop    hl
  124.     jp    cret
  125.  
  126. tickcnt: defb    6        ;Clock is at 300 hz
  127.     defw    TBAUD+1        ;Pointer to Terminal baud rate
  128.     defw    RBAUD+1        ;Pointer to Radio baud rate byte (SCCBI)
  129. ileds:    defb    04h        ;Initial LED Pattern
  130.     defw    SDSI0, SDSI1
  131.     defw    port+1        ;Place where the Port BIT (DTR) is located
  132.  
  133.     global    SDS0, SDS1
  134.  
  135. ;  Initialize the SCC data structures
  136.  
  137. INIT_HDW:
  138.     LD    HL,SDSI0    ;Copy from ROM
  139.     LD    DE,SDS0        ;To RAM
  140.     LD    BC,SDSILEN
  141.     LDIR
  142.  
  143.     LD    HL,SDSI1    ;Copy from ROM
  144.     LD    DE,SDS1        ;To RAM
  145.     LD    BC,SDSILEN
  146.     LDIR
  147.  
  148.     LD    A,MSYNC        ;TNC-320 Clock bit (SYNC)
  149.     LD    (CLKBIT),A    ;Save it
  150.     LD    A,(tickcnt)
  151.     LD    (TICKCNT),A    ;Number of Interrupts/Tick to 10ms
  152.  
  153.     LD    A,09
  154.     LD    C,00
  155.     OUT    (C),A        ;WR 9
  156.     LD    A,0C0H        ;Master Reset for SCC
  157.     OUT    (C),A
  158.  
  159.     LD    A,(port+1)    ;Get Last WR5
  160.     LD    (SDS0+WR5REG),A    ;Save it...
  161.  
  162. ;    Radio Port PTT/DCD is always normal
  163.  
  164.     LD    HL,0FF02h    ;PTTMSK1=MRTS, PTTMSK2=FF
  165.     LD    (SDS0+PTTMSK1),HL
  166.     XOR    A
  167.     LD    B,A        ;DCD is Normal - No Toggle
  168.     LD    (SDS0+DCDTGL),A
  169.  
  170. ;    Is the async port on a NetRom back-to-back cable?
  171.  
  172.     LD    A,(SDS1+CPORT)    ;Async Port
  173.     LD    C,A        ;Port Address
  174.     IN    A,(C)        ;Get RR0 Status
  175.     BIT    CTS,A        ;CTS ON?
  176.     JR    NZ,1f        ;No, Don't Invert RTS and DCD
  177.     LD    HL,7D00h    ;PTTMSK1=00, PTTMSK2=~MRTS
  178.     LD    B,MDCD        ;Toggle DCD Bit
  179.     LD    A,(SDS1+WR5REG)
  180.     OR    MRTS        ;Set the Async PTT to the right idle State
  181.     LD    (SDS1+WR5REG),A
  182. 1:    LD    (SDS1+PTTMSK1),HL ;RTS Handling
  183.     LD    A,B          ;DCD Handling
  184.     LD    (SDS1+DCDTGL),A
  185.  
  186.     LD    IY,SDS0
  187.     CALL    HDLI
  188.     LD    IY,SDS1
  189. ;    CALL    HDLI
  190.     JP    HDLI
  191. ;    RET
  192.  
  193. LATCH    EQU    4    ;Address of LED Latch
  194.  
  195. INIT_LED:        ;Enter with (_COLD) in A and B
  196.     LD    C,LATCH
  197.     AND    0C0H    ;Make sure we only have 2 bits
  198.     SRL    A
  199.     SRL    A
  200.     LD    B,A
  201.     SRL    A
  202.     SRL    A
  203.     OR    B
  204.     OUT    (C),A    ;Do it!
  205.     LD    (HDWbss+1),A    ;Last Write to LEDs
  206.     LD    A,(ileds)
  207.     OR    82H    ;Turn off AUX and PMS bits
  208.     LD    (HDWbss),A    ;This is where we save the LED status
  209.     RET
  210.  
  211. UPD_LED:
  212.     RST    30h        ;call    csv
  213.     LD    A,(HDWbss)    ;Get LEDS
  214.     LD    B,A
  215.     AND    0C3H        ;Save other bits
  216.     LD    C,A
  217.     LD    A,B
  218.     AND    3CH        ;Save LED's we toggle
  219.     SRL    A
  220.     SRL    A        ;Move leds into low 4 bits
  221.     SRL    A        ;Shift Leds Right 1, set CY based on low bit
  222.     JP    NC,1f        ;If no CY, we are OK
  223.     OR    08H
  224. 1:    SLA    A
  225.     SLA    A        ;Move LEDS Back
  226.     OR    C        ;Put other bits back in
  227.     LD    (HDWbss),A
  228.     LD    (HDWbss+1),A    ;Last Write to LEDs
  229.     OUT    (LATCH),A    ;Update LEDS
  230.     RST    38H        ;jp    cret
  231.  
  232. halted:    LD    A,(HDWbss+1)    ;Get Last Write to LEDS
  233.     XOR    80h
  234.     OUT    (LATCH),A
  235.     HALT
  236.     XOR    80h
  237.     OUT    (LATCH),A
  238.     RET
  239.  
  240.     GLOBAL    SDSI0, SDSI1
  241. SDSI0:    DEFB    0        ;Channel number
  242.     DEFB    3        ;SCC data port
  243.     DEFB    1        ;SCC control port
  244.     DEFW    DWAIT0
  245.     DEFW    TXDELAY0
  246.     DEFW    SCCAI        ;SYNC CONFIG
  247.     DEFB    SCCAIL        ;LEN
  248.     DEFB    0        ;Flags
  249.     DEFB    0E9h        ;WR5REG (DTR Now On, Port 1)
  250.  
  251. SDSI1:    DEFB    1        ;Channel number
  252.     DEFB    2        ;SIO data port
  253.     DEFB    0        ;SIO control port
  254.     DEFW    DWAIT1
  255.     DEFW    TXDELAY1
  256.     DEFW    SCCBI        ;8530 Async Config
  257.     DEFB    SCCBIL        ;LEN
  258.     DEFB    MASYNC+MTIMER+MAFT ;Line for timer
  259.     DEFB    0E8h        ;WR5REG DTR is Now ON, RTS Off
  260.     ENDC
  261.  
  262. ;  Fixed data
  263.  
  264. ;  SCC SYNC initialization block.
  265.  
  266. SCCAI:    DEFB    4,0A0H        ;X32, SDLC, Sync
  267.     DEFB    10,0A0H        ;Init CRC, NRZI
  268.     DEFB    7,7EH        ;Sync Definitition (No S!!t)
  269.     DEFB    2,0H        ;Interrupt Vector
  270.     DEFB    3,0DAH        ;8 bit Rx, Enter Hunt, RXCRC, Sync Load Inh.
  271.     DEFB    5,68H        ;8 Bit Tx, Tx Enable
  272. ; next 3 lines are for internal baud rate with external divider for TXC
  273.     DEFB    11,66H    ;RXC=DPLL O/P, TXC=RTxC, TRxC=O, TRxC Out=BRG Out
  274. RBAUD:    DEFB    12,254,13,0    ;Time Constant (300 Baud) (PCLK/(2*32*baud))-2
  275. ;    300 baud = 254, 600 baud = 126, 1200 baud = 62, 9600 baud = 6
  276.     DEFB    14,82H        ;Set Source=BRG, BR Generator source
  277. ; next 2 lines are for external clocks
  278. ;    DEFB    11,68H        ;RXC = DPLL Out, TXC = TRxC, TRxC=IN,
  279. ;    DEFB    14,0A0H        ;DPLL Source = RTxC (x32 clock)
  280. port:    DEFB    5,0E9H        ;DTR On (Port 1),8 bitTx,TxEnable,TX CRC Enable
  281.     DEFB    3,0DBH        ;Same as 3 above, RX Enable
  282.     DEFB    14,23H        ;Enter Search Mode, Enable BRG
  283.     DEFB    15,0E8H        ;Enable Interrupts on 
  284.     DEFB    10H,10H        ;Reset External Interupts, Twice
  285.     DEFB    1,13H        ;Interrupt on Receive and Xmit
  286. SCCAIL    EQU     $-SCCAI
  287.  
  288. ;  SCC ASYNC initialization block.
  289.  
  290. SCCBI:    DEFB    14h        ;WR 4 + Reset Ext Intr
  291.     DEFB    44H        ;16xClk + 1Stop + NoParity
  292.     DEFB    3,0C1H        ;WR3, 8bit + RxEnable
  293.     DEFB    5,0E8H        ;WR5, DTR On + 8bit + TxEnable + RTS Off
  294. ; Internal baud rate generator
  295.     DEFB    11,56H        ;RXC = BRG, TXC = BRG, TRXC OUT, TRXC=BRG
  296. TBAUD:    DEFB    12,14,13,0    ;Time Constant (9600 Baud) (PCLK/(2*16*baud))-2
  297. ;    1200 baud = 126, 2400 = 62, 4800 = 30, 9600 = 14
  298.     DEFB    14,63H        ;Disable PLL, BRG Source, BRG Enable
  299. ; External Clocking
  300. ;    DEFB    11,00H        ;TXC, RXC - RTxC Pin
  301.     DEFB    15,0F8H        ;Enable Interrupts on
  302.     DEFB    10H,10H        ;Reset External Ints
  303.     DEFB    1,13H         ;Enable rx, tx, ext ints
  304.     DEFB    9,9        ;Master Interrupt Enable, Vector Includes Stat
  305. SCCBIL    EQU    $-SCCBI
  306.